﻿#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;

//排序数组中两个数字之和
//https://leetcode.cn/problems/kLl5u1/submissions/
//class Solution {
//public:
//    vector<int> twoSum(vector<int>& numbers, int target) {
//        int begin = 0;
//        int end = numbers.size() - 1;
//
//        while (begin < end)
//        {
//            if (numbers[begin] + numbers[end] == target) return { begin,end };
//            else if (numbers[begin] + numbers[end] > target) --end;
//            else ++begin;
//        }
//
//        return { 1,1 };
//    }
//};

//数组中出现次数超过一半的数字
//https://www.nowcoder.com/questionTerminal/e8a1b01a2df14cb2b228b30ee6a92163?f=discussion
//class Solution {
//public:
//    int MoreThanHalfNum_Solution(vector<int>& numbers) {
//        unordered_map<int, int> m;
//        for (const auto& n : numbers) ++m[n];
//
//        int n = numbers.size() / 2;
//        for (const auto& x : m)
//            if (x.second > n) return x.first;
//
//        return -1;
//    }
//};